<template>
	<view class="button-sp-area">
		<button type="primary" plain="true" @click="showRichAlert()">点击显示弹窗</button>
		<button type="primary" plain="true" @click="toAddMark()">添加水印</button>
	</view>
</template>

<script>
	const modal = uni.requireNativePlugin('modal');
	const dcRichAlert = uni.requireNativePlugin('DCloud-RichAlert');
	const videoModule = uni.requireNativePlugin('VideoModule');
	var sdRoot = plus.io.convertLocalFileSystemURL("/"); //文件夹根目录
	export default {
		data() {
			return {
				title: ''
			};
		},
		onLoad() {},
		methods: {
			toAddMark() {
				uni.chooseImage({
					count: 1, //默认9
					sizeType: ['original'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ['camera'], //从相册选择
					success: function(res) {
						let path = res.tempFilePaths[0];
						uni.saveImageToPhotosAlbum({
							filePath: path,
							success: function(r) {
								videoModule.watermark({
									'taskName': '莒南县创建国家卫生县城暗访',
									'path': r.path,
									'address': '济宁市·任城区·城投星城广场',
									'longitude': 118.844991,
									'latitude': 35.201878,
									'date': '2023-10-19',
									'time': '21:43',
									'week': '星期四'
								}, ret => {
									modal.toast({
										message: ret.thumbUrl,
										duration: 1.5
									});

								});
							}
						});

					}
				});
			},
			getThumb() {
				uni.chooseVideo({
					compressed: false,
					camera: 'back',
					maxDuration: 10,
					success: res => {
						let path = res.tempFilePath;
						videoModule.getVideoThumb({
							path: path,
							packageName: 'com.android.UniPlugin'
						}, ret => {
							console.log(ret);
						});
					}
				});
			},
			showRichAlert() {
				dcRichAlert.show({
						position: 'bottom',
						title: '提示信息',
						titleColor: '#FF0000',
						content: "<a href='https://uniapp.dcloud.io/' value='Hello uni-app'>uni-app</a> 是一个使用 Vue.js 开发跨平台应用的前端框架!\n免费的\n免费的\n免费的\n重要的事情说三遍",
						contentAlign: 'left',
						checkBox: {
							title: '不再提示',
							isSelected: true
						},
						buttons: [{
								title: '取消'
							},
							{
								title: '否'
							},
							{
								title: '确认',
								titleColor: '#3F51B5'
							}
						]
					},
					result => {
						const msg = JSON.stringify(result);
						modal.toast({
							message: msg,
							duration: 1.5
						});
						switch (result.type) {
							case 'button':
								console.log('callback---button--' + result.index);
								break;
							case 'checkBox':
								console.log('callback---checkBox--' + result.isSelected);
								break;
							case 'a':
								console.log('callback---a--' + JSON.stringify(result));
								break;
							case 'backCancel':
								console.log('callback---backCancel--');
								break;
						}
					}
				);
			}

			// 			nvueclick() {
			// 				uni.navigateTo({
			// 					url: '/pages/nvue/index2'
			// 				});
			// 			}
		}
	};
</script>

<style>
	button {
		margin-top: 30upx;
		margin-bottom: 30upx;
	}

	.button-sp-area {
		margin: 0 auto;
		width: 60%;
	}

	.content {
		text-align: center;
		height: 400upx;
	}

	.wrapper {
		flex-direction: column;
		justify-content: center;
	}

	.button {
		width: 200px;
		margin-top: 30px;
		margin-left: 20px;
		padding-top: 20px;
		padding-bottom: 20px;
		border-width: 2px;
		border-style: solid;
		border-color: #458b00;
		background-color: #458b00;
	}

	.text {
		font-size: 30px;
		color: #666666;
		text-align: center;
	}
</style>